package cloud.maque.module.system.controller;

import cloud.maque.common.core.request.PageRequest;
import cloud.maque.common.core.response.R;
import cloud.maque.module.system.entity.SysDictType;
import cloud.maque.module.system.service.DictTypeService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 字典接口
 */
@Tag(name = "字典接口")
@RestController
@RequestMapping(value = "/dict")
public class DictTypeController {


    @Autowired
    DictTypeService dictTypeService;

    @Operation(summary = "字典列表")
    @PostMapping("/list")
    public R<IPage<SysDictType>> List(@RequestBody PageRequest<SysDictType> pageReq) {
        return R.ok("OK", dictTypeService.GetList(pageReq));
    }

    @Operation(summary = "字典保存")
    @PostMapping("/save")
    public R<SysDictType> Save(@RequestBody SysDictType data) {

        return R.ok("OK", dictTypeService.SaveDictType(data));
    }

    @Operation(summary = "字典删除")
    @DeleteMapping("/delete/{id}")
    public R<Boolean> Delete(@PathVariable("id") String id) {
        return R.ok("OK", dictTypeService.DeleteType(id));
    }
}
